package com.tebiecloud.store.server.controller.feign;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.tebiecloud.common.model.ResultBody;
import com.tebiecloud.common.utils.ResultBodyUtils;
import com.tebiecloud.store.client.model.entity.StoreFlow;
import com.tebiecloud.store.client.service.IStoreFlowServiceClient;
import com.tebiecloud.store.server.service.StoreFlowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/feign/flow")
public class FlowController implements IStoreFlowServiceClient {

    @Autowired
    StoreFlowService storeFlowService;

    @PostMapping("saveStoreFlow")
    @Override
    public ResultBody<StoreFlow> saveStoreFlow(@RequestParam("storeId") long storeId, @RequestParam("amount") int amount,
                                               @RequestParam("shareAmount") int shareAmount, @RequestParam("fees") int fees,
                                               @RequestParam("type") int type, @RequestParam("typeId") long typeId,
                                               @RequestParam(value = "desp",required = false) String desp,
                                               @RequestParam("year") int year,
                                               @RequestParam("month") int month,@RequestParam("day") int day) {
        StoreFlow storeFlow = new StoreFlow();
        storeFlow.setStoreId(storeId);
        storeFlow.setAmount(amount);
        storeFlow.setShareAmount(shareAmount);
        storeFlow.setFees(fees);
        storeFlow.setDay(day);
        storeFlow.setDesp(desp);
        storeFlow.setMonth(month);
        storeFlow.setType(type);
        storeFlow.setTypeId(typeId);
        storeFlow.setYear(year);
        storeFlowService.save(storeFlow);
        return ResultBodyUtils.ok(storeFlow);
    }
}
